home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Snippets / Platforms & Tools / MacApp / AEGestalt 1.0b3 / UAEClientCommand.cp < prev    next >
Encoding:
Text File  |  1991-12-11  |  2.3 KB  |  82 lines  |  [TEXT/MPS ]

  1. //    UAEClientCommand.cp
  2. //     Copyright © 1991 by Apple Computer, Inc. All rights reserved.
  3. //    Kent Sandvik DTS
  4. //    This file contains all the TAEClientCommand member functions, i.e.
  5. //    for creating an Apple event which will query a server over the network.
  6.  
  7.  
  8. #ifndef __AECLIENTCOMMAND__
  9. #include "UAEClientCommand.h"
  10. #endif
  11.  
  12.  
  13. //    Empty constructor - for avoiding ptabs in global data space
  14. #pragma segment ARes
  15. TAEClientCommand::TAEClientCommand() {}                    
  16.  
  17. //     Put together the client AppleEvent, which will call the server asking for
  18. //    Gestalt information
  19.  
  20. #pragma segment ASelCommand
  21. pascal void TAEClientCommand::IAEClientCommand(        CommandNumber     theNum,
  22.                                                     TAEDocument*    theDocument,
  23.                                                     AEEventID        theID)
  24. {
  25.     AEAddressDesc     theAddress;
  26.     FailInfo        fi;
  27.     
  28.     fDocument = theDocument;                        // save document wherefrom command is issued
  29.     
  30.     this->IClientCommand(theNum, theDocument, kCantUndo, kDoesNotCauseChange, NULL);
  31.     
  32.     if(fi.Try()){
  33.         // setup fMessage to contain the data for our Gestalt GetData AppleEvent
  34.  
  35.         theDocument->GetAEGestaltAddress(theAddress);
  36.         
  37.         TAppleEvent* aMessage = new TAppleEvent;                // create AE object
  38.         aMessage->IAppleEvent(kMacAppClass, theID, theAddress, kAEQueueReply);
  39.         fMessage = aMessage;
  40.     
  41.         fi.Success();
  42.     }
  43.     else{
  44.         this->Free();
  45.         fi.ReSignal();
  46.     }
  47. }
  48.  
  49.  
  50. //    Process replies that gets back to the client side from the AE server
  51.  
  52. #pragma segment ADoCommand
  53. pascal void TAEClientCommand::ProcessReply(TAppleEvent* theReply)
  54. {
  55.     CStr255                    theResponse;
  56.     long                    actualSize;
  57.     DescType                actualCode;
  58.     struct Configuration    tempConfig;
  59.  
  60.     inherited::ProcessReply(theReply);            // handle inherited processing
  61.     FailOSErr(theReply->ReadShort('errn'));        // check for AE errors    
  62.  
  63.     // if OK, continue processing the reply - store it in the document
  64.     theReply->ReadParameterPtr(kAEConfig, typeConfig, actualCode,
  65.                                 (Ptr)&tempConfig, 
  66.                                 sizeof(Configuration), actualSize);
  67.  
  68.     // Now move the tempConfig to the fDocument itself.
  69.     fDocument->ReadConfiguration(&tempConfig);
  70.     
  71.     // FUTURE: Make a TProcessGestaltCommand which will process the information
  72.     // and store it in the TInformationView
  73.     // TProcessGestaltCommand aCommand = new TProcessGestaltCommand(this,tempConfig);
  74.     // and so on...
  75.  
  76.     // Process the reply to a more suitable format, this is done from the
  77.     // document itself for the view class
  78.     
  79.     fDocument->ProcessAEInformation();
  80. }
  81.  
  82.